Skip to content

refactor(plugin-chatbot): move ChatbotEnhanced types, subcomponents and helpers into chat/ - #37799

Merged
os-zhuang merged 1 commit into
mainfrom
claude/project-thread-dvvo6j
Nov 27, 2026
Merged

os-zhuang merged 1 commit into
mainfrom
claude/project-thread-dvvo6j

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Jack · project thread

Fixes #37728

Clause-②: no
Metadata-protocol: none

维护者速读

What changes

A move-only split of ui/packages/plugin-chatbot/src/ChatbotEnhanced.tsx: 3335 → 1514 lines. The file keeps the ChatbotEnhanced component, formatMessageProps and the two PLAIN_SURFACE_* constants, and re-exports by name (export { … } from, export type { … } from, no export *) every symbol it exported before. Every existing import path keeps working, so FloatingChatbot, chatMessageAdapter, mapMessages, renderer, toolResultParsers, useAiModels, useHitlInChat and the tests are untouched.

New modules under src/chat/, exactly as the card lists them:

File Symbols
types.ts ChatbotEnhancedMessage, ChatbotEnhancedToolInvocation, ChatChart, ChatSource, ChatbotLabels, ChatbotEnhancedProps, ChatbotProcessVisibility, ChatbotSurface, ChatbotModelOption, ToolDecisionState, TurnLiveness
ModelPicker.tsx ModelPicker, drawnMultiplierOf, EXPENSIVE_MODEL_MULTIPLIER, OUTSIDE_MODELS
liveness.tsx useTurnLiveness, LivenessIndicator, LIVENESS_QUIET_AFTER_SECONDS, useIsOffline, formatElapsed, ThinkingDots, AssistantThinkingMessage, MessageAvatar
toolSummary.tsx getToolState, getToolStateRank, ToolSummaryState, ToolSummaryGroup, shouldRenderDetailedTool, summarizeTools, ToolPhaseSummary, ToolPhaseStep, foldToolPhaseSteps, isPlumbingTool, PLUMBING_TOOL_NAMES, ToolActivitySummary, ToolActivitySummaryLabels, ToolSummaryIcon, getToolSummaryStatus, ToolRunningTimer, usePhaseElapsed, phaseClock, SmartToolOutput, looksLikeJson
answerLayout.tsx layoutAnswer, AnswerBlock, AnswerCharts, isToolCallPlaceholder
toolRecordWrite.ts writtenRecordOf, formatRecordWriteValue
composerNotices.tsx ErrorBanner, ComposerNotice, SendErrorNotice, formatSizeLimit, useAiQuotaCopy

Every top-level declaration of the old file is named in the card, so no private helper had to be placed by judgement and none stayed behind.

  • One phaseClock. The module-level Map moved with usePhaseElapsed into toolSummary.tsx; there is no other copy.
  • Dependency direction. toolSummary → liveness (ToolRunningTimer reads useIsOffline and formatElapsed), every module → types. No new module imports ChatbotEnhanced.tsx, and types.ts reaches ../mapMessages with import type only.
  • Exports. A moved symbol is exported from its new module only when another file uses it, or when the old file exported it.
  • Frozen entries. plugin-chatbot/src/index.tsx, plugin-chatbot/src/core.ts and app-shell/src/index.ts have an empty diff.

The split was generated by a script that works from symbol names (TypeScript AST), not line numbers. It was first run on #37720's head and re-run on main after #37720 landed; the second run produced byte-identical files.

Why

Card #37728, split A of topic #37690. Upcoming chat changes (feedback, approval cards, a thinking timeline) all land in this file; split B (#37729) moves renderToolDetail next and builds on toolRecordWrite.ts.

Verification

git diff --color-moved=zebra --stat origin/main..HEAD
 .changeset/37728-chatbot-enhanced-split-a.md       |   10 +
 ui/packages/plugin-chatbot/src/ChatbotEnhanced.tsx | 1901 +-------------------
 .../plugin-chatbot/src/chat/ModelPicker.tsx        |  219 +++
 .../plugin-chatbot/src/chat/answerLayout.tsx       |  107 ++
 .../plugin-chatbot/src/chat/composerNotices.tsx    |  237 +++
 ui/packages/plugin-chatbot/src/chat/liveness.tsx   |  300 +++
 .../plugin-chatbot/src/chat/toolRecordWrite.ts     |   35 +
 .../plugin-chatbot/src/chat/toolSummary.tsx        |  471 +++++
 ui/packages/plugin-chatbot/src/chat/types.ts       |  590 ++++++
 9 files changed, 2009 insertions(+), 1861 deletions(-)

The deleted lines and the added lines differ only in import/export lines: comparing the two multisets of the diff, what is not in both is import specifiers, the new re-export block, export added in front of moved declarations, and each new file's license header and one-paragraph module comment. Nothing else changed.

Readings on head 2ed21c64, against main 6e8f6637:

  • pnpm run type-check in ui/packages/plugin-chatbot (tsc --noEmit and tsc -p tsconfig.test.json): exit 0.
  • pnpm run build in ui/packages/plugin-chatbot: exit 0.
  • pnpm --dir ui exec vitest run packages/plugin-chatbot/ packages/core/src/utils/__tests__/column-identity.ratchet.test.ts: 70 files, 668 tests passed.
  • eslint over ChatbotEnhanced.tsx and src/chat/: 0 errors, 9 warnings. Before the split the file had 2 warnings (one react-refresh/only-export-components, one react-hooks/set-state-in-effect). The 7 new ones are all react-refresh/only-export-components: the card's layout puts components and helpers in the same modules (for example liveness.tsx exports formatElapsed beside ThinkingDots). It is a fast-refresh hint, no gate counts warnings, and splitting further would leave the card's layout.
  • dispatch-gates, all 32 derived commands: exit 0, including pnpm --dir ui exec vitest run scripts/ (which covers one-authority-per-exported-name-6273), check-adr-0087-registration --base origin/main, check-empty-changeset, check-changeset-no-major and check:test-source-alias. Also pnpm check:changeset-fixed, pnpm --dir ui check:new-line-citations (0 new) and check-platform-checklist --changed-from origin/main: exit 0.
  • overlap-check: merges cleanly with main, no open PR shares a file.

Changeset: .changeset/37728-chatbot-enhanced-split-a.md, patch for @object-ui/plugin-chatbot, with both declaration lines.


Generated by Claude Code

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q4EjjMaLacWen8f2akYQCJ

… and helpers into chat/

A move-only split with no behaviour change. ChatbotEnhanced.tsx keeps the
component, formatMessageProps and the plain-surface constants, and re-exports
by name every symbol it exported before.

Claude-Session: https://claude.ai/code/session_01Q4EjjMaLacWen8f2akYQCJ
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/xl tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

对话组件拆分 A:把 ChatbotEnhanced.tsx 的类型、子组件和工具函数搬到独立文件(不改行为)

3 participants